using System.Collections.Generic;
using CodePlex.TfsLibrary;
using CodePlex.TfsLibrary.ObjectModel;

namespace CodePlex.UnitTestUtility
{
    public class StubPatchEngine : IPatchEngine
    {
        public List<SourceItemCallbackData> ApplyPatch__CallbackData = new List<SourceItemCallbackData>();
        public string ApplyPatch_Directory;
        public string ApplyPatch_PatchXml;
        public List<SourceItemCallbackData> CreatePatch__CallbackData = new List<SourceItemCallbackData>();
        public string CreatePatch__Result;
        public string CreatePatch_Directory;

        public void ApplyPatch(string directory,
                               string patchXml,
                               SourceItemCallback callback)

        {
            ApplyPatch_Directory = directory;
            ApplyPatch_PatchXml = patchXml;

            if (callback != null)
                foreach (SourceItemCallbackData data in ApplyPatch__CallbackData)
                    callback(data.SourceItem, data.SourceItemResult);
        }

        public string CreatePatch(string directory,
                                  SourceItemCallback callback)
        {
            CreatePatch_Directory = directory;

            if (callback != null)
                foreach (SourceItemCallbackData data in CreatePatch__CallbackData)
                    callback(data.SourceItem, data.SourceItemResult);

            return CreatePatch__Result;
        }
    }
}